<?php
/*
*	created by cbq in 2017.02.08
*	站点相关模型
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Linkclass_m extends MY_Model {
    public function __construct()
    {
        parent::__construct();
        $this->table='linkclass';
    }
    //友情链接分类列表
    public function ajaxall($where=array(),$field="*",$order='classid desc'){
        $pagesize=getConfig('pagesize');
        $this->com_where($where);
        $this->db->select('count(classid) as counts');
        $query=$this->db->get($this->table);
        $counts=$query->row_array();

        $page=isset($_REQUEST['page'])?$_REQUEST['page']:1;
        $startRow=$pagesize * ($page - 1);
        $this->com_where($where);
        $this->db->select($field);
        $this->db->order_by($order);
        $this->db->limit($pagesize,$startRow);
        $query2=$this->db->get($this->table);
        $data['list']=$query2->result_array();
        $data['pageshow']=$this->pageajax_show($pagesize,$counts['counts']);
        return $data;
    }
	//查询所有
	public function selall($where=array(),$field="*",$order='classid desc'){
		$this->com_where($where);
        $this->db->select($field);
        $this->db->order_by($order);
        $query=$this->db->get($this->table);
        return $query->result_array();
	}
    //查询单条用户信息
    public function sel($where=array(),$field="*"){
    	$this->com_where($where);
    	$this->db->select($field);
        $query=$this->db->get($this->table);
     	$data=$query->row_array();
        return $data;
    }
    //添加站点
    public function add($data){
        $this->db->insert($this->table,$data);
        return $this->db->insert_id();
    }
    //编辑友情链接分类
    public function edit($where,$data){
        $this->com_where($where);
        $this->db->update($this->table,$data);
        return $this->db->affected_rows();
    }
    //删除友情链接分类
    public function del($where){
        $this->com_where($where);
        $this->db->delete($this->table);
        return $this->db->affected_rows();
    }
}
?>